#ifndef MIDDLEWINDOW_H
#define MIDDLEWINDOW_H
#include <QMainWindow>
#include "diffie_hellman.h"
#include "aes_gcm.h"
#include <pcap.h>
#include <string.h>
#include <stdlib.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <net/ethernet.h>
#include <QObject>
#include <QThread>
#include "diffie_hellman.h"
//void processPacket(u_char *arg, const struct pcap_pkthdr* pkthdr, const u_char * packet);

void set_psdheader(struct psd_header* ph,struct iphdr *ip, uint16_t tl);
unsigned char* getkey(int k);
uint16_t calc_cksm(void *pkt, int len);
typedef struct{
    unsigned char client_ip[16];
    unsigned char server_ip[16];
    pcap_t *p;
}ip_rule;

struct psd_header{
    unsigned int saddr;
    unsigned int daddr;
    char mbz;
    char ptcl;
    unsigned short tcpl;
};

class Sendv : public QObject
{
    Q_OBJECT
public:
    Sendv()
    {
        ;
    }
public:
    void pre_sendValue(QString qstr1);//这里改参数传值

signals:
    void sendValue(QString);//这里改参数传值

};

class Cappackets : public QThread
{
    Q_OBJECT
public:
    pcap_t *descr = NULL;
    static void processPacket(u_char *arg, const struct pcap_pkthdr* pkthdr, const u_char * packet);
    int cap_start(char *addr[]);
protected:
    void run()
    {
        char* t[5];
        memset(t, 0, 20);
        cap_start(t);
    }
public:
    void stop()
    {
        pcap_breakloop(descr);
    }
};

namespace Ui {
class middlewindow;
}

class middlewindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit middlewindow(QWidget *parent = 0);
    ~middlewindow();


private slots:
    void on_pushButton_clicked();

    void on_pushButton_2_clicked();

    void getValue(QString);//这两句复制到接受方的QT类里

private:
    Ui::middlewindow *ui;


};

#endif // MIDDLEWINDOW_H
